home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / stdio / bug3.c < prev    next >
C/C++ Source or Header  |  1992-08-06  |  765b  |  53 lines

  1. #include <ansidecl.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int
  6. DEFUN_VOID(main)
  7. {
  8.   FILE *f;
  9.   int i;
  10.  
  11.   f = fopen("bugtest", "w+");
  12.   for (i=0; i<9000; i++)
  13.     putc ('x', f);
  14.   fseek (f, 8180L, 0);
  15.   fwrite ("Where does this text go?", 1, 24, f);
  16.   fflush (f);
  17.  
  18.   rewind (f);
  19.   for (i=0; i<9000; i++)
  20.     {
  21.       int j;
  22.  
  23.       if ((j = getc(f)) != 'x')
  24.     {
  25.       if (i != 8180)
  26.         {
  27.           printf ("Test FAILED!");
  28.           return 1;
  29.         }
  30.       else
  31.         {
  32.           char buf[25];
  33.  
  34.           buf[0] = j;
  35.           fread (buf + 1, 1, 23, f);
  36.           buf[24] = '\0';
  37.           if (strcmp (buf, "Where does this text go?") != 0)
  38.         {
  39.           printf ("%s\nTest FAILED!\n", buf);
  40.           return 1;
  41.         }
  42.           i += 23;
  43.         }
  44.     }
  45.     }
  46.  
  47.   fclose(f);
  48.  
  49.   puts ("Test succeeded.");
  50.  
  51.   return 0;
  52. }
  53.